package com.es.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 描述:
 * es-servlet-
 *
 * @author Derek
 * 创建时间：2022-04-21 10:41
 */
@WebServlet(urlPatterns = "/d")
public class DServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("我是DServlet");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.println("您的年龄是："+req.getParameter("age"));
        out.println("<br>C中放的flag是："+req.getAttribute("flag"));
        out.println("<br>Session中的name:"+req.getSession().getAttribute("name"));
        out.println("<br>ServletContext中的name:"+this.getServletContext().getAttribute("name"));
        out.flush();
    }
}
